/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.partagenote;

import java.util.*;
import java.io.*;
import java.text.*;

/**
 *
 * @author Anselmatus
 */
public class PotCommun extends Evenement {

    private ArrayList<Facture> listeFactures;

    public PotCommun(String nom) {
        super(nom);
        listeFactures = new ArrayList<Facture>();
    }

    @Override
    public void initMembre(int nbPers) {
        Personne pers;
        Scanner compt = new Scanner(System.in);

        for (int cpt = 1; cpt <= nbPers; cpt++) {
            System.out.println("Nom de la " + cpt + " personne :");
            String nomParticipant = compt.nextLine();
            pers = new Personne(nomParticipant);
            this.listeParticipants.add(pers);
        }
    }

    public void initFacture(int nbFact) {
        Facture fact;
        Scanner compt = new Scanner(System.in);

        for (int cpt = 1; cpt <= nbFact; cpt++) {

            System.out.println("Descriptif de la " + cpt + " facture :");
            String desc = compt.nextLine();
            System.out.println("Somme de la " + cpt + " facture :");
            double somme = compt.nextDouble();
            fact = new Facture(desc, somme);
            this.listeFactures.add(fact);
        }
    }

    @Override
    public double calculSommeFactureTotale() {
        double calcSommeFactureTotal = 0;
        Object[] factureListe = this.listeFactures.toArray();
        for (Object facture : factureListe) {
            Facture facturePtCom = (Facture) facture;
            calcSommeFactureTotal += facturePtCom.getSomme();
        }
        return calcSommeFactureTotal;
    }

    public double calculSommeTotale() {
        return 0;
    }
}
